package com.wjf.concurrency.example.singleton;

import com.wjf.concurrency.annoations.ThreadSafe;

/*
* 懒汉模式
* 单例实例在第一次运行时进行创建
* */
@ThreadSafe
public class SingletonExample3 {

    //私有的构造函数
    private SingletonExample3(){

    }
    //单例对象
    public static SingletonExample3 intance=null;

    //静态的工厂方法
    public static synchronized SingletonExample3 getInstance(){
        if (intance ==null){
            intance=new SingletonExample3();
        }
        return intance;
    }
}
